package com.learn.redis.test;

import org.junit.Before;
import org.junit.Test;
import redis.clients.jedis.Jedis;

/**
 * @author DYZ
 * @date 2021/8/25
 */
public class RedisTestSet {

    Jedis jedis;

    @Before
    public void setUp() {
        jedis = new Jedis("192.168.2.23", 6379);
    }

    @Test
    public void ping() {
        // 添加
        jedis.sadd("Learn","Java");
        jedis.sadd("Learn","Redis");
        jedis.sadd("Learn","Jedis");
        jedis.sadd("Learn","Spring");

        // 移除
        jedis.srem("Learn","Spring");

        // 获取所有value
        System.out.println(jedis.smembers("Learn"));
        // 判断
        System.out.println(jedis.sismember("Learn", "Redis"));

        System.out.println(jedis.srandmember("Learn"));
        // 返回集合的元素个数
        System.out.println(jedis.scard("Learn"));
    }

}
//[Jedis, Redis, Java]
//true
//Jedis
//3